package com.coordinate.core.factory.impl;

import java.util.HashMap;
import java.util.Properties;

import com.coordinate.core.factory.ServiceProviderFactory;
import com.coordinate.core.kernel.serviceprovider.ServiceProvider;
import com.coordinate.core.kernel.serviceprovider.impl.CEmailServiceProvider;
import com.coordinate.core.kernel.serviceprovider.impl.CSmsServiceProvider;
import com.coordinate.core.kernel.serviceprovider.impl.CText2SpeechVoiceCallProvider;
import com.coordinate.core.kernel.serviceprovider.impl.CVideoCallServiceProvider;
import com.coordinate.core.kernel.serviceprovider.impl.CVoiceCallServiceProvider;
import com.coordinate.core.type.DeliveryChannelType;

public class CServiceProviderFactory implements ServiceProviderFactory {
   
	private static CServiceProviderFactory mInstance = null;
	
	HashMap mServiceProvidersMap = new HashMap();
	
	public CServiceProviderFactory()
	{
		
	}
	
	public static ServiceProviderFactory createServiceProviderFactory(Properties pProps)
	{
		
		if(mInstance == null )
		{
			mInstance = new CServiceProviderFactory();
			mInstance.createServiceProviders(pProps);
		}
				
		return mInstance;
	}
	
	private  void createServiceProviders(Properties pProps) {
		// check if the Props is null for Service Provider,
		//  load default , else process it
		// load appropriate classes from Properties configuration
		//for()
		//TODO : make this programtic, later
		
		this.mServiceProvidersMap.put("email", new CEmailServiceProvider());
		this.mServiceProvidersMap.put("sms",new CSmsServiceProvider() );
		this.mServiceProvidersMap.put("voicecall",new CVoiceCallServiceProvider() );
		this.mServiceProvidersMap.put("text2speech",new CText2SpeechVoiceCallProvider() );
		this.mServiceProvidersMap.put("video",new CVideoCallServiceProvider() );
		
	}

	public ServiceProvider getServiceProvider(String pChannel) {
		ServiceProvider lSp = null;
		lSp = (ServiceProvider) this.mServiceProvidersMap.get(pChannel);
	    return lSp;
	}
	
	

}
